<?php


?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript" src="../../js/jquery-1.9.1.min.js"></script>
</head>
<body>
<table align="center" width="1000" cellpadding="0" cellspacing="1" style="border:1px solid #CCC">
  <tr bgcolor="#EEE" height="24">
    <td>接口地址</td>
    <td>method</td>
  </tr>
  <tr bgcolor="#F9F9F9" height="24">
    <td><select id="api_host">
<?php
	foreach($hosts as $host){
?>
      <option value="<?php echo $host?>"><?php echo $host?></option>
<?php
	}
?>
    </select><?php echo $url?></td>
    <td><?php echo $method?></td>
  </tr>
</table>
<br>
<table align="center" width="1000" cellpadding="0" cellspacing="1" style="border:1px solid #CCC">
  <form id="requestform" method="<?php echo $method?>">
  <tr bgcolor="#EEE" height="24">
    <td>参数名</td>
    <td>参数</td>
    <td>必填</td>
    <td>类型</td>
    <td>说明</td>
  </tr>
<?php
	if($api["isAuth"]){
?>
  <tr bgcolor="#F9F9F9" height="24">
    <td>Authorization</td>
    <td><input name="Authorization" type="text" value=""/></td>
    <td>是</td>
    <td>string</td>
    <td>token</td>
  </tr>
<?php
	}
?>
  <tr bgcolor="#F9F9F9" height="24">
    <td>title</td>
    <td><input name="title" type="text" value=""/></td>
    <td>是</td>
    <td>string</td>
    <td>标题</td>
  </tr>
  <tr bgcolor="#F9F9F9" height="24">
    <td>content</td>
    <td><input name="content" type="text" value=""/></td>
    <td>是</td>
    <td>string</td>
    <td>内容</td>
  </tr>
  <tr bgcolor="#F9F9F9" height="24">
    <td>activity_id</td>
    <td><input name="activity_id" type="text" value=""/></td>
    <td>否</td>
    <td>int</td>
    <td>活动ID</td>
  </tr>
  <tr bgcolor="#F9F9F9" height="24">
    <td>files</td>
    <td><input name="files" type="text" value=""/></td>
    <td>是</td>
    <td>json</td>
    <td>图片视频</td>
  </tr>

  <tr bgcolor="#F9F9F9" height="24">
    <td colspan="5" align="center"><input type="button" value="提交" onclick="request()"/></td>
  </tr>
  </form>
</table>
<script language="javascript">

function request(){
	
	var isAuth = <?php echo $isAuth ? 'true' : 'false'?>;
	var api_id = "<?php echo $api["id"]?>";
	var url = "<?php echo $url?>";
	var api_host_obj = $('#api_host');
	var method = "<?php echo $method?>";
	
	var $form = $('#requestform');
	
	$form.attr('method', method);

	if(isAuth){
		var api_id = $('<input type="text" name="api_id" value="'+api_id+'"/>');
		var api_host = $('<input type="text" name="api_host" value="'+api_host_obj.val()+'"/>');
		$form.append(api_id);  
		$form.append(api_host);  
		$form.attr('action', "/info/asyncCreate");
	}else{
		$form.attr('action', api_host.val()+url);
	}
	
	$form.submit();

}


</script>
</body>
</html>